using System; 
using System.Text; 
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration; 
using System.Xml; 
using System.Xml.Serialization;
using SubSonic; 
using SubSonic.Utilities;

namespace Adex
{
	/// <summary>
	/// Strongly-typed collection for the TblAddressbok class.
	/// </summary>
	[Serializable]
	public partial class TblAddressbokCollection : ActiveList<TblAddressbok, TblAddressbokCollection> 
	{	   
		public TblAddressbokCollection() {}

	}

	/// <summary>
	/// This is an ActiveRecord class which wraps the tblAddressboks table.
	/// </summary>
	[Serializable]
	public partial class TblAddressbok : ActiveRecord<TblAddressbok>
	{
		#region .ctors and Default Settings
		
		public TblAddressbok()
		{
		  SetSQLProps();
		  InitSetDefaults();
		  MarkNew();
		}

		
		private void InitSetDefaults() { SetDefaults(); }

		
		public TblAddressbok(bool useDatabaseDefaults)
		{
			SetSQLProps();
			if(useDatabaseDefaults)
				ForceDefaults();
			MarkNew();
		}

		public TblAddressbok(object keyID)
		{
			SetSQLProps();
			InitSetDefaults();
			LoadByKey(keyID);
		}

		 
		public TblAddressbok(string columnName, object columnValue)
		{
			SetSQLProps();
			InitSetDefaults();
			LoadByParam(columnName,columnValue);
		}

		
		protected static void SetSQLProps() { GetTableSchema(); }

		
		#endregion
		
		#region Schema and Query Accessor
		public static Query CreateQuery() { return new Query(Schema); }

		
		public static TableSchema.Table Schema
		{
			get
			{
				if (BaseSchema == null)
					SetSQLProps();
				return BaseSchema;
			}

		}

		
		private static void GetTableSchema() 
		{
			if(!IsSchemaInitialized)
			{
				//Schema declaration
				TableSchema.Table schema = new TableSchema.Table("tblAddressboks", TableType.Table, DataService.GetInstance("Adex"));
				schema.Columns = new TableSchema.TableColumnCollection();
				schema.SchemaName = @"dbo";
				//columns
				
				TableSchema.TableColumn colvarId = new TableSchema.TableColumn(schema);
				colvarId.ColumnName = "ID";
				colvarId.DataType = DbType.Int32;
				colvarId.MaxLength = 0;
				colvarId.AutoIncrement = true;
				colvarId.IsNullable = false;
				colvarId.IsPrimaryKey = true;
				colvarId.IsForeignKey = false;
				colvarId.IsReadOnly = false;
				colvarId.DefaultSetting = @"";
				colvarId.ForeignKeyTableName = "";
				schema.Columns.Add(colvarId);
				
				TableSchema.TableColumn colvarEmailID = new TableSchema.TableColumn(schema);
				colvarEmailID.ColumnName = "EmailID";
				colvarEmailID.DataType = DbType.String;
				colvarEmailID.MaxLength = 350;
				colvarEmailID.AutoIncrement = false;
				colvarEmailID.IsNullable = false;
				colvarEmailID.IsPrimaryKey = false;
				colvarEmailID.IsForeignKey = false;
				colvarEmailID.IsReadOnly = false;
				colvarEmailID.DefaultSetting = @"";
				colvarEmailID.ForeignKeyTableName = "";
				schema.Columns.Add(colvarEmailID);
				
				BaseSchema = schema;
				//add this schema to the provider
				//so we can query it later
				DataService.Providers["Adex"].AddSchema("tblAddressboks",schema);
			}

		}

		#endregion
		
		#region Props
		
		  
		[XmlAttribute("Id")]
		public int Id 
		{
			get { return GetColumnValue<int>("ID"); }

			set { SetColumnValue("ID", value); }

		}

		  
		[XmlAttribute("EmailID")]
		public string EmailID 
		{
			get { return GetColumnValue<string>("EmailID"); }

			set { SetColumnValue("EmailID", value); }

		}

		
		#endregion
		
		
			
		
		//no foreign key tables defined (0)
		
		
		
		//no ManyToMany tables defined (0)
		
		#region ObjectDataSource support
		
		
		/// <summary>
		/// Inserts a record, can be used with the Object Data Source
		/// </summary>
		public static void Insert(string varEmailID)
		{
			TblAddressbok item = new TblAddressbok();
			
			item.EmailID = varEmailID;
			
		
			if (System.Web.HttpContext.Current != null)
				item.Save(System.Web.HttpContext.Current.User.Identity.Name);
			else
				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name);
		}

		
		/// <summary>
		/// Updates a record, can be used with the Object Data Source
		/// </summary>
		public static void Update(int varId,string varEmailID)
		{
			TblAddressbok item = new TblAddressbok();
			
				item.Id = varId;
				
				item.EmailID = varEmailID;
				
			item.IsNew = false;
			if (System.Web.HttpContext.Current != null)
				item.Save(System.Web.HttpContext.Current.User.Identity.Name);
			else
				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name);
		}

		#endregion
		#region Columns Struct
		public struct Columns
		{
			 public static string Id = @"ID";
			 public static string EmailID = @"EmailID";
						
		}

		#endregion
	}

}

